import numpy as np
import mindspore as ms
import mindspore.nn as nn
import mindspore.ops as ops
from mindspore.ops import functional as F
from mindspore.common.initializer import initializer


class TestNet(nn.Cell):
    def __init__(self):
        super(TestNet, self).__init__()
        self.op = nn.SmoothL1Loss()

    def construct(self, input_x, labels):
        out = self.op(input_x,labels)
        return [out]


if __name__ == "__main__":
    net = TestNet()

    input_x = ms.Tensor(np.ones([10,64]), ms.float32)
    labels = ms.Tensor(np.random.random_sample([10, 64]), ms.float32)
    result = net(input_x, labels)
    print(result[0])
    print(result[0].shape)
